<template>
	<div class="darkBg">
		<div class="container">
			<div class="zlList">
				<div class="item" v-for="(item,index) in zlList" :key="index" @click="read(item)">
					<div class="img">
						<image :src="item.img" mode="widthFix"></image>
						<div class="state">{{item.state}}</div>
					</div>
					<div class="intro">
						<h4>{{item.title}}</h4>
						<div class="btn">
							<u-button text="领取PDF" size="small" plain type="success" :customStyle="btnStyle" @click.native.stop="showEwm()" ></u-button>
							<u-button text="点击查看" size="small" type="error" :customStyle="btnStyle"></u-button>
						</div>
					</div>
				</div>
			</div>
			<div class="comList">
				<u-popup :show="ewmShow" @close="ewmShow = false"  mode="center" >
					<view>
						<div class="ewmBox">
							<image src="https://www.baixuemianshi.com/zhuanti/images/lynn.jpg" mode="widthFix" show-menu-by-longpress="true"></image>
							<p>添加老师微信 <br>	领取PDF资料</p>
						</div>
					</view>
				</u-popup>
			</div>
		</div>

		<share></share>
		<u-toast ref="uToast"></u-toast>
		
	</div>
</template>

<script>
import { mapActions } from 'vuex';
import share from '../../common/share/index.vue';
const db = wx.cloud.database()
export default {
	data() {
		return {
			ewmShow:false,
			zlid:"",
			zlList:[],
			btnStyle: {
				"width": "46%"
			},
		};
	},
	onShareAppMessage(options) {
		let shareObj = {
		    title: "雪恒白雪-面试资料领取",
		    path: '/pages/sk-tools/zllq/index',
		    imageUrl: ''   
		};
		return shareObj
	},
	onShow() {},
	onPullDownRefresh() {
		console.log('refresh');
		setTimeout(function() {
			uni.stopPullDownRefresh();
		}, 1000);
	},
	onPageScroll(e) {
		let that = this;
		that.scrollTop = e.scrollTop;
	},
	onLoad(options) {
		if (!options) {} else {
			this.zlid = options.zlid
		}
	},
	computed: {
		userphone() {
			return this.$store.getters.userphone ? this.$store.getters.userphone : '';
		}
	},
	mounted() {
		
		this.getZl()
	},
	watch: {
		userphone(val){
			
		}
	},
	created() {
		let that = this;
	},
	methods: {
		...mapActions(['LogSetSearchtimes','LogSetPhone','LogSetOpenid','LogSetName','LogSetPage']),
		
		getZl(){
			let that = this
			db.collection('pdf_cols').doc(that.zlid).get({
				success: res => {
					that.zlList = res.data.lists
				}
			})
		},
		read(b){
			let that = this
			uni.navigateTo({
				url:"../../webview/index?href=" + encodeURIComponent('https://www.baixuemianshi.com/zhuanti/pdf_view3/generic-legacy/web/viewer.html?file=' + b.link)
			})
			
		},
		showEwm(){
			this.ewmShow = true
		},
		showToast(type, info) {
			this.$refs.uToast.show({
				type: type,
				icon: false,
				title: '失败主题',
				message: info,
			})
		},
		imgView(imgUrl) {
			wx.previewImage({
				urls: [imgUrl], //需要预览的图片http链接列表，注意是数组
				current: '', // 当前显示图片的http链接，默认是第一个
				success: function(res) {},
				fail: function(res) {},
				complete: function(res) {}
			});
		}
	},
	components: { share}
};
</script>

<style>
@import url(./index.css);
</style>
